Use the GTK selection types rather than GtkTreeSelectionMode.
authorJonathan Blandford <jrb@redhat.com>
Mon, 27 Aug 2001 19:19:24 +0000 (19:19 +0000)
committerJonathan Blandford <jrb@src.gnome.org>
Mon, 27 Aug 2001 19:19:24 +0000 (19:19 +0000)
Mon Aug 27 15:18:14 2001  Jonathan Blandford  <jrb@redhat.com>

* gtk/gtktreeselection.c (gtk_tree_selection_set_mode): Use the
GTK selection types rather than GtkTreeSelectionMode.

* docs/Changes-2.0: Add comment about selection change.

12 files changed:
ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
docs/Changes-2.0.txt
gtk/gtkenums.h
gtk/gtktreeselection.c
gtk/gtktreeselection.h
gtk/gtktreeview.c

index 2dfb82e933548462c1c7d2be4af06c9765e75cd2..ea714aeaa9d427c2f44c3ac5c273ecccbe3ee9f6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Mon Aug 27 15:18:14 2001  Jonathan Blandford  <jrb@redhat.com>
+
+       * gtk/gtktreeselection.c (gtk_tree_selection_set_mode): Use the
+       GTK selection types rather than GtkTreeSelectionMode.
+
+       * docs/Changes-2.0: Add comment about selection change.
+
 Mon Aug 27 14:21:30 2001  Jonathan Blandford  <jrb@redhat.com>
 
        * gtk/gtkenums.h (GtkSelectionMode): deprecate
index 2dfb82e933548462c1c7d2be4af06c9765e75cd2..ea714aeaa9d427c2f44c3ac5c273ecccbe3ee9f6 100644 (file)
@@ -1,3 +1,10 @@
+Mon Aug 27 15:18:14 2001  Jonathan Blandford  <jrb@redhat.com>
+
+       * gtk/gtktreeselection.c (gtk_tree_selection_set_mode): Use the
+       GTK selection types rather than GtkTreeSelectionMode.
+
+       * docs/Changes-2.0: Add comment about selection change.
+
 Mon Aug 27 14:21:30 2001  Jonathan Blandford  <jrb@redhat.com>
 
        * gtk/gtkenums.h (GtkSelectionMode): deprecate
index 2dfb82e933548462c1c7d2be4af06c9765e75cd2..ea714aeaa9d427c2f44c3ac5c273ecccbe3ee9f6 100644 (file)
@@ -1,3 +1,10 @@
+Mon Aug 27 15:18:14 2001  Jonathan Blandford  <jrb@redhat.com>
+
+       * gtk/gtktreeselection.c (gtk_tree_selection_set_mode): Use the
+       GTK selection types rather than GtkTreeSelectionMode.
+
+       * docs/Changes-2.0: Add comment about selection change.
+
 Mon Aug 27 14:21:30 2001  Jonathan Blandford  <jrb@redhat.com>
 
        * gtk/gtkenums.h (GtkSelectionMode): deprecate
index 2dfb82e933548462c1c7d2be4af06c9765e75cd2..ea714aeaa9d427c2f44c3ac5c273ecccbe3ee9f6 100644 (file)
@@ -1,3 +1,10 @@
+Mon Aug 27 15:18:14 2001  Jonathan Blandford  <jrb@redhat.com>
+
+       * gtk/gtktreeselection.c (gtk_tree_selection_set_mode): Use the
+       GTK selection types rather than GtkTreeSelectionMode.
+
+       * docs/Changes-2.0: Add comment about selection change.
+
 Mon Aug 27 14:21:30 2001  Jonathan Blandford  <jrb@redhat.com>
 
        * gtk/gtkenums.h (GtkSelectionMode): deprecate
index 2dfb82e933548462c1c7d2be4af06c9765e75cd2..ea714aeaa9d427c2f44c3ac5c273ecccbe3ee9f6 100644 (file)
@@ -1,3 +1,10 @@
+Mon Aug 27 15:18:14 2001  Jonathan Blandford  <jrb@redhat.com>
+
+       * gtk/gtktreeselection.c (gtk_tree_selection_set_mode): Use the
+       GTK selection types rather than GtkTreeSelectionMode.
+
+       * docs/Changes-2.0: Add comment about selection change.
+
 Mon Aug 27 14:21:30 2001  Jonathan Blandford  <jrb@redhat.com>
 
        * gtk/gtkenums.h (GtkSelectionMode): deprecate
index 2dfb82e933548462c1c7d2be4af06c9765e75cd2..ea714aeaa9d427c2f44c3ac5c273ecccbe3ee9f6 100644 (file)
@@ -1,3 +1,10 @@
+Mon Aug 27 15:18:14 2001  Jonathan Blandford  <jrb@redhat.com>
+
+       * gtk/gtktreeselection.c (gtk_tree_selection_set_mode): Use the
+       GTK selection types rather than GtkTreeSelectionMode.
+
+       * docs/Changes-2.0: Add comment about selection change.
+
 Mon Aug 27 14:21:30 2001  Jonathan Blandford  <jrb@redhat.com>
 
        * gtk/gtkenums.h (GtkSelectionMode): deprecate
index 2dfb82e933548462c1c7d2be4af06c9765e75cd2..ea714aeaa9d427c2f44c3ac5c273ecccbe3ee9f6 100644 (file)
@@ -1,3 +1,10 @@
+Mon Aug 27 15:18:14 2001  Jonathan Blandford  <jrb@redhat.com>
+
+       * gtk/gtktreeselection.c (gtk_tree_selection_set_mode): Use the
+       GTK selection types rather than GtkTreeSelectionMode.
+
+       * docs/Changes-2.0: Add comment about selection change.
+
 Mon Aug 27 14:21:30 2001  Jonathan Blandford  <jrb@redhat.com>
 
        * gtk/gtkenums.h (GtkSelectionMode): deprecate
index 9b2371f07dd465ccfdcb032ff2d35ae6245f40cf..97799cb9528e382f2282e5141e6738886627d219 100644 (file)
@@ -454,3 +454,8 @@ Incompatible Changes from GTK+-1.2 to GTK+-2.0:
 * gtk_image_new() now takes no arguments and creates an empty GtkImage
   widget. To create a GtkImage widget from a GdkImage (the least
   common usage of GdkImage), use gtk_image_new_from_image.
+
+* GTK_SELECTION_EXTENDED is now deprecated, and neither the
+  GtkList/GtkTree nor the GtkCList/GtkCTree support
+  GTK_SELECTION_EXTENDED anymore.  However, the old extended behavior
+  replaces MULTIPLE behavior.
index 94c5c0d09e2ccddd600e8f03cf07a23caa629892..b62414ccd2977e5c8fe2d55a14c169c6b45ecd97 100644 (file)
@@ -320,7 +320,7 @@ typedef enum
   GTK_SELECTION_SINGLE,
   GTK_SELECTION_BROWSE,
   GTK_SELECTION_MULTIPLE,
-  GTK_SELECTION_EXTENDED == GTK_SELECTION_MULTIPLE /* Deprecated */
+  GTK_SELECTION_EXTENDED = GTK_SELECTION_MULTIPLE /* Deprecated */
 } GtkSelectionMode;
 
 /* Shadow types */
index fe74d602ca7b3a8676de81ea4af1c3aa7f52c716..b09d00781389f07b188db26cd6e03d5b27d1caa5 100644 (file)
@@ -91,7 +91,7 @@ gtk_tree_selection_class_init (GtkTreeSelectionClass *class)
 static void
 gtk_tree_selection_init (GtkTreeSelection *selection)
 {
-  selection->type = GTK_TREE_SELECTION_SINGLE;
+  selection->type = GTK_SELECTION_SINGLE;
 }
 
 static void
@@ -169,19 +169,20 @@ _gtk_tree_selection_set_tree_view (GtkTreeSelection *selection,
  * @type: The selection mode
  *
  * Sets the selection mode of the @selection.  If the previous type was
- * #GTK_TREE_SELECTION_MULTI and @type is #GTK_TREE_SELECTION_SINGLE, then
- * the anchor is kept selected, if it was previously selected.
+ * #GTK_SELECTION_MULTIPLE and, then the anchor is kept selected, if it was
+ * previously selected.
  **/
 void
-gtk_tree_selection_set_mode (GtkTreeSelection     *selection,
-                            GtkTreeSelectionMode  type)
+gtk_tree_selection_set_mode (GtkTreeSelection *selection,
+                            GtkSelectionMode  type)
 {
   g_return_if_fail (GTK_IS_TREE_SELECTION (selection));
 
   if (selection->type == type)
     return;
 
-  if (type == GTK_TREE_SELECTION_SINGLE)
+  if (type == GTK_SELECTION_SINGLE ||
+      type == GTK_SELECTION_BROWSE)
     {
       GtkRBTree *tree = NULL;
       GtkRBNode *node = NULL;
@@ -227,10 +228,10 @@ gtk_tree_selection_set_mode (GtkTreeSelection     *selection,
  *
  * Return value: the current selection mode
  **/
-GtkTreeSelectionMode
+GtkSelectionMode
 gtk_tree_selection_get_mode (GtkTreeSelection *selection)
 {
-  g_return_val_if_fail (GTK_IS_TREE_SELECTION (selection), GTK_TREE_SELECTION_SINGLE);
+  g_return_val_if_fail (GTK_IS_TREE_SELECTION (selection), GTK_SELECTION_SINGLE);
 
   return selection->type;
 }
@@ -290,10 +291,10 @@ gtk_tree_selection_get_tree_view (GtkTreeSelection *selection)
  * @iter: The #GtkTreeIter, or NULL.
  *
  * Sets @iter to the currently selected node if @selection is set to
- * #GTK_TREE_SELECTION_SINGLE.  @iter may be NULL if you just want to test if
- * @selection has any selected nodes.  @model is filled with the current model
- * as a convenience.  This function will not work if you use @selection is
- * #GTK_TREE_SELECTION_MULTI.
+ * #GTK_SELECTION_SINGLE or #GTK_SELECTION_BROWSE.  @iter may be NULL if you
+ * just want to test if @selection has any selected nodes.  @model is filled
+ * with the current model as a convenience.  This function will not work if you
+ * use @selection is #GTK_SELECTION_MULTIPLE.
  *
  * Return value: TRUE, if there is a selected node.
  **/
@@ -308,7 +309,7 @@ gtk_tree_selection_get_selected (GtkTreeSelection  *selection,
   gboolean retval;
 
   g_return_val_if_fail (GTK_IS_TREE_SELECTION (selection), FALSE);
-  g_return_val_if_fail (selection->type == GTK_TREE_SELECTION_SINGLE, FALSE);
+  g_return_val_if_fail (selection->type != GTK_SELECTION_MULTIPLE, FALSE);
   g_return_val_if_fail (selection->tree_view != NULL, FALSE);
   g_return_val_if_fail (selection->tree_view->priv->model != NULL, FALSE);
 
@@ -380,7 +381,8 @@ gtk_tree_selection_selected_foreach (GtkTreeSelection            *selection,
       selection->tree_view->priv->tree->root == NULL)
     return;
 
-  if (selection->type == GTK_TREE_SELECTION_SINGLE)
+  if (selection->type == GTK_SELECTION_SINGLE ||
+      selection->type == GTK_SELECTION_BROWSE)
     {
       if (gtk_tree_row_reference_valid (selection->tree_view->priv->anchor))
        {
@@ -492,7 +494,7 @@ gtk_tree_selection_select_path (GtkTreeSelection *selection,
   if (node == NULL || GTK_RBNODE_FLAG_SET (node, GTK_RBNODE_IS_SELECTED))
     return;
 
-  if (selection->type == GTK_TREE_SELECTION_MULTI)
+  if (selection->type == GTK_SELECTION_MULTIPLE)
     state = GDK_CONTROL_MASK;
 
   _gtk_tree_selection_internal_select_node (selection,
@@ -652,8 +654,8 @@ gtk_tree_selection_real_select_all (GtkTreeSelection *selection)
  * gtk_tree_selection_select_all:
  * @selection: A #GtkTreeSelection.
  *
- * Selects all the nodes.  @selection is must be set to
- * #GTK_TREE_SELECTION_MULTI mode.
+ * Selects all the nodes.  @selection is must be set to #GTK_SELECTION_MULTIPLE
+ * mode.
  **/
 void
 gtk_tree_selection_select_all (GtkTreeSelection *selection)
@@ -662,7 +664,7 @@ gtk_tree_selection_select_all (GtkTreeSelection *selection)
   g_return_if_fail (selection->tree_view != NULL);
   if (selection->tree_view->priv->tree == NULL)
     return;
-  g_return_if_fail (selection->type != GTK_TREE_SELECTION_MULTI);
+  g_return_if_fail (selection->type != GTK_SELECTION_MULTIPLE);
 
   if (gtk_tree_selection_real_select_all (selection))
     g_signal_emit (G_OBJECT (selection), tree_selection_signals[CHANGED], 0);
@@ -692,7 +694,8 @@ gtk_tree_selection_real_unselect_all (GtkTreeSelection *selection)
 {
   struct _TempTuple *tuple;
 
-  if (selection->type == GTK_TREE_SELECTION_SINGLE)
+  if (selection->type == GTK_SELECTION_SINGLE ||
+      selection->type == GTK_SELECTION_BROWSE)
     {
       GtkRBTree *tree = NULL;
       GtkRBNode *node = NULL;
@@ -881,10 +884,12 @@ _gtk_tree_selection_internal_select_node (GtkTreeSelection *selection,
   if (selection->tree_view->priv->anchor)
     anchor_path = gtk_tree_row_reference_get_path (selection->tree_view->priv->anchor);
 
-  if (selection->type == GTK_TREE_SELECTION_SINGLE)
+  if (selection->type == GTK_SELECTION_SINGLE ||
+      selection->type == GTK_SELECTION_BROWSE)
     {
       /* Did we try to select the same node again? */
-      if (anchor_path && gtk_tree_path_compare (path, anchor_path) == 0)
+      if (selection->type == GTK_SELECTION_SINGLE &&
+         anchor_path && gtk_tree_path_compare (path, anchor_path) == 0)
        {
          if ((state & GDK_CONTROL_MASK) == GDK_CONTROL_MASK)
            {
@@ -921,7 +926,7 @@ _gtk_tree_selection_internal_select_node (GtkTreeSelection *selection,
            }
        }
     }
-  else if (selection->type == GTK_TREE_SELECTION_MULTI)
+  else if (selection->type == GTK_SELECTION_MULTIPLE)
     {
       if (((state & GDK_SHIFT_MASK) == GDK_SHIFT_MASK) && (anchor_path == NULL))
        {
@@ -983,12 +988,6 @@ _gtk_tree_selection_internal_select_node (GtkTreeSelection *selection,
 /* NOTE: Any {un,}selection ever done _MUST_ be done through this function!
  */
 
-/* FIXME: user_func can screw up GTK_TREE_SELECTION_SINGLE.  If it prevents
- * unselection of a node, it can keep more then one node selected.
- */
-/* Perhaps the correct solution is to prevent selecting the new node, if
- * we fail to unselect the old node.
- */
 static gint
 gtk_tree_selection_real_select_node (GtkTreeSelection *selection,
                                     GtkRBTree        *tree,
index d349337a456a78f3b433eb03c22756bd666434aa..11286bdabff3b7e5db748454b35a5cf29bda0ea7 100644 (file)
@@ -34,12 +34,6 @@ extern "C" {
 #define GTK_IS_TREE_SELECTION_CLASS(klass)     (GTK_CHECK_CLASS_TYPE ((obj), GTK_TYPE_TREE_SELECTION))
 #define GTK_TREE_SELECTION_GET_CLASS(obj)       (GTK_CHECK_GET_CLASS ((obj), GTK_TYPE_TREE_SELECTION, GtkTreeSelectionClass))
 
-typedef enum
-{
-  GTK_TREE_SELECTION_SINGLE,
-  GTK_TREE_SELECTION_MULTI
-} GtkTreeSelectionMode;
-
 typedef gboolean (* GtkTreeSelectionFunc)    (GtkTreeSelection  *selection,
                                              GtkTreeModel      *model,
                                              GtkTreePath       *path,
@@ -56,7 +50,7 @@ struct _GtkTreeSelection
   /*< private >*/
   
   GtkTreeView *tree_view;
-  GtkTreeSelectionMode type;
+  GtkSelectionMode type;
   GtkTreeSelectionFunc user_func;
   gpointer user_data;
   GtkDestroyNotify destroy;
@@ -73,8 +67,8 @@ struct _GtkTreeSelectionClass
 GtkType          gtk_tree_selection_get_type            (void);
 
 void             gtk_tree_selection_set_mode            (GtkTreeSelection            *selection,
-                                                        GtkTreeSelectionMode         type);
-GtkTreeSelectionMode gtk_tree_selection_get_mode        (GtkTreeSelection            *selection);
+                                                        GtkSelectionMode             type);
+GtkSelectionMode gtk_tree_selection_get_mode        (GtkTreeSelection            *selection);
 void             gtk_tree_selection_set_select_function (GtkTreeSelection            *selection,
                                                         GtkTreeSelectionFunc         func,
                                                         gpointer                     data,
index 05815800be86f83fed9a48f3e5d9f9561062f98a..42cedc9511f6e80ba3667a22a3f5c60836115640 100644 (file)
@@ -5693,10 +5693,10 @@ gtk_tree_view_focus_to_cursor (GtkTreeView *tree_view)
       cursor_path = gtk_tree_path_new_root ();
       gtk_tree_row_reference_free (tree_view->priv->cursor);
 
-      if (tree_view->priv->selection->type == GTK_TREE_SELECTION_SINGLE)
-       gtk_tree_view_real_set_cursor (tree_view, cursor_path, TRUE);
-      else
+      if (tree_view->priv->selection->type == GTK_SELECTION_MULTIPLE)
        gtk_tree_view_real_set_cursor (tree_view, cursor_path, FALSE);
+      else
+       gtk_tree_view_real_set_cursor (tree_view, cursor_path, TRUE);
     }
   gtk_tree_path_free (cursor_path);
 }